package com.evl.api.qrcode.service.impl;

import java.text.MessageFormat;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.evl.api.qrcode.service.IWeiXinService;
import com.evl.api.qrcode.vo.TemplateRQ;
import com.evl.core.support.WeiXinKit;
import com.evl.core.weixin.WeixinHandler;
import com.google.gson.Gson;
@Service
public class WeiXinServiceImpl implements IWeiXinService {

	@Resource
	WeixinHandler weixinHandler;
	
	@Override
	public String sendTemplate(TemplateRQ templateRQ) {

		String accessToken=weixinHandler.getBasicAccessToken();
    	String url=weixinHandler.getTemplateUrl();
    	url=MessageFormat.format(url, accessToken);
    	
    	Gson gson=new Gson();
    	String params=gson.toJson(templateRQ);
    	String res= WeiXinKit.httpRequest(url, "POST", params);
		return res;
	}

}
